package leecode

func subsets(nums []int) (result [][]int) {
	path := make([]int, 0, len(nums))
	var backtracking func(startIndex int)
	backtracking = func(startIndex int) {
		temp := make([]int, len(path))
		copy(temp, path)
		result = append(result, temp)
		for i := startIndex; i < len(nums); i++ {
			path = append(path, nums[i])
			backtracking(i + 1)
			path = path[:len(path)-1]
		}
	}
	backtracking(0)
	return
}
